package com.ssh.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import org.junit.Test;

public class InputTest {
	@Test
	public void test01() {
		File file = new File("E:\\upload\\io\\input.txt");
		try(InputStream input = new FileInputStream(file);) {
			int temp;
			while((temp = input.read()) != -1) {
				System.out.print((char)temp);
			}
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
	}
	
	@Test
	public void test02() {
		File file = new File("E:\\upload\\io\\input.txt");
		try(InputStream input = new FileInputStream(file);) {
			byte[] buffer = new byte[10];
			while(input.read(buffer) != -1) {
				for (int i = 0, n = buffer.length; i < n; i++) {
					System.out.print((char)buffer[i]);
				}
			}
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
	}
}
